<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>超市进销存管理系统</title>

    <!-- Bootstrap -->
    <link href="${pageContext.request.contextPath }/statics/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="${pageContext.request.contextPath }/statics/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="${pageContext.request.contextPath }/statics/css/nprogress.css" rel="stylesheet">
    <!-- Animate.css -->
    <link href="${pageContext.request.contextPath }/statics/css/animate.min.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="${pageContext.request.contextPath }/statics/css/custom.min.css" rel="stylesheet">
</head>

<body class="login">
<div>
    <a class="hiddenanchor" id="signup"></a>
    <a class="hiddenanchor" id="signin"></a>

    <div class="login_wrapper">
        <div class="animate form login_form">
            <section class="login_content">
                <form action="manage/dologin" method="post" id="formlogin">
                    <h1>超市进销存管理系统</h1>
                    <h2 id="loginname">管理员登录</h2>
                    <div>
                        <input type="text" class="form-control" name="managerid" placeholder="请输入用户名" required="" />
                    </div>
                    <div>
                        <input type="password" class="form-control" name="pwd" placeholder="请输入密码" required="" />
                    </div>
                    <div>
                        <span>角色</span>
                        <input type="radio" name="type" value="管理员" checked>管理员</input>
                        <input type="radio" name="type" value="员工">员工</input>
                        <hr/>
                    </div>
                    <span>${error}</span>
                    <div>
                        <button type="submit" class="btn btn-success">登     录</button>
                        <button type="reset" class="btn btn-default">重　填</button>
                    </div>

                    <div class="clearfix"></div>

                    <div class="separator">
                        <div>
                            <p>@2022 Binvor </p>
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>
</body>
<script>
    // 获取所有的 radio 元素
    var radios = document.querySelectorAll('input[type="radio"]');
    // 遍历每个 radio 元素
    radios.forEach(function(radio) {
        // 添加点击事件监听器
        radio.addEventListener('click', function() {
            // 获取被点击的 radio 的值
            var selectedColor = this.value;
            document.getElementById("loginname").innerText=selectedColor+"登录";
            var myForm = document.getElementById('formlogin');
            if(selectedColor=="管理员"){
                myForm.action = "manage/dologin";
            }else{
                myForm.action = "staff/dologin";
            }
            // 在控制台输出被点击的 radio 的值
            console.log('你选择了：' + selectedColor);
            // 在这里可以执行其他操作，例如根据选中的颜色改变页面样式等
        });
    });
</script>
</html>